PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index PDFsharp - moved to http://forum.pdfsharp.net/
Please visit the new PDFsharp forum at http://forum.pdfsharp.net/
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Bug with Adding text to split pages

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index -> Bug Reports - moved to http://forum.pdfsharp.net/
View previous topic :: View next topic  
Author Message
mdreyer



Joined: 24 Jul 2007
Posts: 2

PostPosted: Tue Jul 24, 2007 3:09 pm    Post subject: Bug with Adding text to split pages Reply with quote

Hello,

I have a multi-page PDF document that I need to split, add some text and then save the pdf page to a BLOB SQL Server field. I created a simple Proof of concept to test if this tool will work for me.

I open the source document in import mode, split into an individual page in a new document, close the new document, reopen the new document in Modify mode, draw some text, save the new document and close it.

I get no errors, however no text is added to the new document page.

What am I doing wrong?

Here is the source code:

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim inputdoc As PdfDocument = PdfReader.Open(txtPDFFile.Text, PdfDocumentOpenMode.Import)

For index As Integer = 0 To inputdoc.PageCount - 1
Dim page As PdfPage = inputdoc.Pages(index)
''inputdoc.Save(txtPDFFile.Text)

Dim filename As String = inputdoc.FullPath.Substring(0, inputdoc.FullPath.LastIndexOf(".pdf")) + _
"(Page " + String.Format("{0:000}", index + 1) + ").pdf"
Dim outputdoc As New PdfDocument(filename)
outputdoc.Pages.Add(page)
outputdoc.Close()

' reopen the new doc to modify and add the unique number
Dim newdoc As PdfDocument = PdfReader.Open(filename, PdfDocumentOpenMode.Modify)
For i As Integer = 0 To newdoc.PageCount - 1
Dim NewPage As PdfPage = newdoc.Pages(i)

Dim gfx As PdfSharp.Drawing.XGraphics = PdfSharp.Drawing.XGraphics.FromPdfPage(NewPage)
Dim font As New PdfSharp.Drawing.XFont("Verdana", 10, XFontStyle.Regular)
gfx.DrawString(TextBox1.Text.ToString(), font, XBrushes.Black, 20, 20, XStringFormat.Default)
newdoc.Save(filename)

newdoc.Close()
Next
Next

inputdoc.Close()
MessageBox.Show("Done...")
Me.Close()
End Sub
Back to top
View user's profile Send private message
mdreyer



Joined: 24 Jul 2007
Posts: 2

PostPosted: Tue Jul 24, 2007 4:08 pm    Post subject: This does not work either... Reply with quote

Does not give me an error...just does not write anything to the pdf file

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim inputdoc As PdfDocument = PdfReader.Open(txtPDFFile.Text, PdfDocumentOpenMode.Import)

For index As Integer = 0 To inputdoc.PageCount - 1

Dim page As PdfPage = inputdoc.Pages(index)

Dim filename As String = inputdoc.FullPath.Substring(0, inputdoc.FullPath.LastIndexOf(".pdf")) + _
"(Page " + String.Format("{0:000}", index + 1) + ").pdf"

Dim outputdoc As New PdfDocument()
Dim pagetmp As PdfPage = outputdoc.Pages.Add(page)
Dim gfx As PdfSharp.Drawing.XGraphics = _
PdfSharp.Drawing.XGraphics.FromPdfPage(pagetmp, XGraphicsPdfPageOptions.Append)
Dim font As New PdfSharp.Drawing.XFont("Verdana", 18, XFontStyle.Regular)

gfx.DrawString(TextBox1.Text.ToString(), font, XBrushes.Black, 30, 50, XStringFormat.Default)
outputdoc.Save(filename)
outputdoc.Close()

' reopen the new doc to modify and add the unique number
'Dim newdoc As PdfDocument = PdfReader.Open(filename, PdfDocumentOpenMode.Modify)
'For i As Integer = 0 To newdoc.PageCount - 1
' Dim NewPage As PdfPage = newdoc.Pages(i)

' Dim gfx As PdfSharp.Drawing.XGraphics = PdfSharp.Drawing.XGraphics.FromPdfPage(NewPage)
' Dim font As New PdfSharp.Drawing.XFont("Verdana", 10, XFontStyle.Regular)
' gfx.DrawString(TextBox1.Text.ToString(), font, XBrushes.Black, 20, 20, XStringFormat.Default)
' newdoc.Save(filename)

' newdoc.Close()
'Next
Next

inputdoc.Close()
MessageBox.Show("Done...")
Me.Close()
End Sub
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index -> Bug Reports - moved to http://forum.pdfsharp.net/ All times are GMT
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © phpBB Group. Hosted by phpBB.BizHat.com


Start Your Own YouTube Clone

Free Web Hosting | Free Forum Hosting | FlashWebHost.com | Image Hosting | Photo Gallery | FreeMarriage.com

Powered by PhpBBweb.com, setup your forum now!
For Support, visit Forums.BizHat.com