pdf writer for uwp
The name is SokeePdfLib.
With this you can create PDF document in UWP (C#) environment.
pdf writer for uwp
A few years ago, I've tried to find PDF Writing Open Source. But I've failed to find it. So I've made it by myself and it is uploading to github now. PDFShart or SharpPDF was refered to make my own pdf library (SokeePdfLib).
It's not perfect. But it's simple to expand to meet your requirement.
refer HowWrite/MainPage.xaml.cs
PDF is just a format. The following shows how to write a file with PDF format.
StorageFile file = await DownloadsFolder.CreateFileAsync("sample.pdf", CreationCollisionOption.GenerateUniqueName);
With this code, "sample.pdf" will be created at Download folder of yours.
await WriteToAsync(file, "%PDF-1.4");
await WriteToAsync(file, "1 0 obj <>");
await WriteToAsync(file, "endobj");
await WriteToAsync(file, "2 0 obj <>");
await WriteToAsync(file, "endobj");
await WriteToAsync(file, "3 0 obj<>");
await WriteToAsync(file, "endobj");
await WriteToAsync(file, "4 0 obj<>>>");
await WriteToAsync(file, "endobj");
await WriteToAsync(file, "5 0 obj<>");
await WriteToAsync(file, "endobj");
await WriteToAsync(file, "6 0 obj");
await WriteToAsync(file, "<>");
await WriteToAsync(file, "stream");
await WriteToAsync(file, "BT /F1 24 Tf 175 720 Td (Hello World!)Tj ET");
await WriteToAsync(file, "endstream");
await WriteToAsync(file, "endobj");
await WriteToAsync(file, "xref");
await WriteToAsync(file, "0 7");
await WriteToAsync(file, "0000000000 65535 f");
await WriteToAsync(file, "0000000009 00000 n");
await WriteToAsync(file, "0000000056 00000 n");
await WriteToAsync(file, "0000000111 00000 n");
await WriteToAsync(file, "0000000212 00000 n");
await WriteToAsync(file, "0000000250 00000 n");
await WriteToAsync(file, "0000000317 00000 n");
await WriteToAsync(file, "trailer <>");
await WriteToAsync(file, "startxref");
await WriteToAsync(file, "406");
await WriteToAsync(file, "%%EOF");
You can find the pdf in the "sample.pdf" file.
refer UwpPdf/MainPage.xaml.cs
SokeePdfLib is a library to write PDF file.
private async void DoTestAsync(object sender, RoutedEventArgs e)
{
PdfDocument doc = new PdfDocument();
pdfPage page = doc.addPage();
page.addText("Hello PDF 10, 0", 10, 0, SokeePdfLib.Enumerators.predefinedFont.csCourier, 24, SokeePdfLib.Enumerators.predefinedColor.csBlack);
//await manuplateImageAsync(page, 10, 0);
await addImageOn(page);
pdfPage page2 = doc.addPage();
page2.addText("Hello PDF 10, 100", 10, 100, SokeePdfLib.Enumerators.predefinedFont.csCourier, 24, SokeePdfLib.Enumerators.predefinedColor.csBlack);
//await manuplateImageAsync(page2, 10, 100);
await addImageOn(page2);
pdfPage page3 = doc.addPage();
page3.addText("Hello PDF 10, 200", 10, 200, SokeePdfLib.Enumerators.predefinedFont.csCourier, 24, SokeePdfLib.Enumerators.predefinedColor.csBlack);
//await manuplateImageAsync(page3, 10, 200);
await addImageOn(page3);
doc.CreatePDFAsync("hello.pdf");
}
}
You can find the pdf in the "hello.pdf" file in your Download folder.