PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Mar 29, 2024 8:44 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Wed Jun 08, 2016 5:12 pm 
Offline

Joined: Fri May 13, 2016 5:44 pm
Posts: 6
I am creating a barcode PDF file. I want the barcode to take up most of the space on the page, but I also want the product name in smaller font underneath.

My page dimensions are 4" x 1" (these dimensions fit a label size)

No matter what I do, setting the height to 1" always produces a line break between the 2 paragraphs of text. If I set the height to 2", then it works. The barcode is always on the first page, which is exactly what I want, but the product name never is displayed with it.

Here is my code:
Code:
Document document = new Document();

            Section section = document.AddSection();
            section.PageSetup.PageWidth = "4in";
            section.PageSetup.PageHeight = "1in";

            Paragraph paragraph = section.AddParagraph();

            paragraph.Format.Font.Name = "CODE39_FONT";
            paragraph.Format.Font.Size = 48;
            paragraph.Format.SpaceBefore = -65;
            paragraph.Format.LeftIndent = -45;
            paragraph.AddText("0023516890992315");

            paragraph = section.AddParagraph("Product Name Goes Here");
            paragraph.Format.Font.Size = 10;
            paragraph.Format.PageBreakBefore = false;
            paragraph.Format.SpaceBefore = 5;
            paragraph.Format.LeftIndent = -45;

            PdfDocumentRenderer renderer = new PdfDocumentRenderer(false, PdfFontEmbedding.Always);
            renderer.Document = document;
            renderer.RenderDocument();

            renderer.PdfDocument.Save("barcode.pdf");
            Process.Start("barcode.pdf");


Any help will be greatly appreciated. Thanks.


Top
 Profile  
Reply with quote  
PostPosted: Wed Jun 08, 2016 7:28 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 909
Location: CCAA
Hi!

PageSetup has more values. You do not set top and bottom margins. Not sure, but this could be the problem.

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 14, 2016 4:15 pm 
Offline

Joined: Fri May 13, 2016 5:44 pm
Posts: 6
Thanks TH-Soft!

I'll try that out.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 184 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group