Sign In  Sign Up Live-Chat

Printing PDF

Last post 10-14-2007, 9:56 AM by seawolf. 4 replies.
Sort Posts: Previous Next
  •  10-12-2007, 10:08 AM 98431

    Printing PDF

    Attachment: Present (inaccessible)
    I am trying to print a PDF file with the PDFViewer and am getting an entirely black page instead of the filled out form that it should be.

    Dim viewer as New Aspose.Pdf.Kit.PdfViewer
    viewer.openpdffile(outputfile)
    viewer.printdocumentwithsetup()
    viewer.closepdfFile()

    Attached is the PDF file.

    I'm assuming that it's because the PDF format is too new.  Any idea when you'll be supporting the latest PDF file format?  Right now I'm looking at shelling to get Adobe Reader to do the printing, not the most elegent solution.


    Allen
     
  •  10-12-2007, 12:32 PM 98453 in reply to 98431

    Re: Printing PDF

    Hi,

    Thank you for considering Aspose.

    I am unable to reproduce this error. I have checked it with latest version 2.6.2.0 of Aspose.Pdf.Kit. Please make sure that you are using the latest version of Aspose.Pdf.Kit.

    Thanks.

     
  •  10-12-2007, 2:31 PM 98475 in reply to 98453

    Re: Printing PDF

    Attachment: Present (inaccessible)
    Okay, the printing now works, but stuff that worked before doesn't work now.  The original source PDF file didn't change when I upgraded the Aspose component, but now I get the error that's at the end of this post.
        This is the line that gives the error:
            Dim mend As New PdfFileMend(inStream, outStream)

    Allen

        Dim bc As New Aspose.BarCode.BarCodeBuilder

        bc.SymbologyType = Symbology.Pdf417
        bc.CodeText = "072583427000010001" & vbCrLf & "9/15/2007" _
          & vbCrLf & "05" & vbCrLf & "83-999" & vbCrLf & "10281" _
          & vbCrLf & "S" & vbCrLf & "DOE,JANE" & vbCrLf & "JLB" _
          & vbCrLf & "MV(-140)" & vbCrLf & vbCrLf & "40001268"
        bc.CodeLocation = CodeLocation.None
        bc.AutoSize = True
        bc.Pdf417ErrorLevel = Pdf417ErrorLevel.Level2

        Dim Caption As New Aspose.BarCode.Caption("071233427000000000")
        Caption.Visible = True
        Caption.TextAlign = StringAlignment.Center
        Caption.Font = New Font("Times New Roman", 17, Drawing.FontStyle.Bold)

        bc.CaptionBelow = Caption
        bc.CaptionAbove.Visible = False

        bc.Columns = 8
        bc.yDimension = 2

        Dim memStream As New MemoryStream
        bc.Save(memStream, ImageFormat.Jpeg)

        Dim inputFile As String = "g:\aes\Barcodes\mv-140.pdf"
        Dim outputFile As String = "g:\aes\BarCodes\071233427000000000.pdf"

        Dim inStream As New FileStream(inputFile, FileMode.Open)
        Dim outStream As New FileStream(outputFile, FileMode.Create)

        inStream.Seek(0, SeekOrigin.Begin)
        Dim mend As New PdfFileMend(inStream, outStream)
        mend.AddImage(memStream, 1, 350, 720, 580, 800)
        mend.Close()

        mend.Close()
        outStream.Seek(0, SeekOrigin.Begin)
        Dim form As New Aspose.Pdf.Kit.Form(inStream, outStream)

        Dim fld As String

        For Each fld In form.FieldsNames
          If fld.GetTypeCode <> TypeCode.String Then
            MsgBox(fld.GetTypeCode())
          End If
          form.FillField(fld, fld)
        Next

        form.Save()

        outStream.Close()
        inStream.Close()

        Dim viewer As New Aspose.Pdf.Kit.PdfViewer
        viewer.OpenPdfFile(outputFile)
        Dim ps As New System.Drawing.Printing.PrinterSettings
        Dim page As New System.Drawing.Printing.PageSettings
        ps.PrinterName = "HP LaserJet 4300 PCL 6"
        viewer.PrintDocumentWithSettings(page, ps)
        viewer.ClosePdfFile()
        MsgBox("Done")

    Give's this error when trying to open PDF:

    System.IO.IOException was unhandled
      Message="Invalid pdf format:pdf head signature is not found!"
      Source="Aspose.Pdf.Kit"
      StackTrace:
           at xeb116a323308e2f7.xa780c1549f927915.checkPdfHeader()
           at xeb116a323308e2f7.x7759a935a2782a02.readPdf()
           at xeb116a323308e2f7.x7759a935a2782a02..ctor(Stream is_Renamed, SByte[] ownerPassword)
           at xeb116a323308e2f7.x7759a935a2782a02..ctor(Stream is_Renamed)
           at Aspose.Pdf.Kit.Form.xedff4d4fd296f454()
           at Aspose.Pdf.Kit.Form..ctor(Stream srcStream, Stream destStream)
           at ActivePDF.Form1.btnMV140_Click(Object sender, EventArgs e)
           at System.Windows.Forms.Control.OnClick(EventArgs e)
           at System.Windows.Forms.Button.OnClick(EventArgs e)
           at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
           at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
           at System.Windows.Forms.Control.WndProc(Message& m)
           at System.Windows.Forms.ButtonBase.WndProc(Message& m)
           at System.Windows.Forms.Button.WndProc(Message& m)
           at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
           at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
           at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
           at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
           at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
           at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
           at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
           at System.Windows.Forms.Application.Run(ApplicationContext context)
           at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
           at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
           at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
           at ActivePDF.My.MyApplication.Main(String[] Args)
           at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
           at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()

     
  •  10-12-2007, 9:41 PM 98495 in reply to 98475

    Re: Printing PDF

    I have reproduced this error and logged this issue as PDFKITNET-3905. We will try to fix it soon.

    Tommy Wang
    Lead Developer
    Aspose Changsha Team
    About Us
    Contact Us
     
  •  10-14-2007, 9:56 AM 98530 in reply to 98475

    Re: Printing PDF

    Hi astoner,

    We have fixed the bug "Invalid pdf format:pdf head signature is not found!" when using PdfFileMend.

    Furthermore,I have test your code, In order to finish your task, there maybe exist some problems in your code. I think the right code is like below. Please notic the red part.

    BTW:we will release a new version soon, and the new version have solove the problem.

        Dim inputFile As String = "g:\aes\Barcodes\mv-140.pdf"
        Dim outputFile As String = "g:\aes\BarCodes\071233427000000000.pdf"
       
        Dim inStream As New FileStream(inputFile, FileMode.Open)
        Dim outStream As New FileStream(outputFile, FileMode.Create)
        Dim tempStream As New MemoryStream()
        inStream.Seek(0, SeekOrigin.Begin)
        Dim mend As New PdfFileMend(inStream, tempStream)
        mend.AddImage(memStream, 1, 350, 720, 580, 800)
        mend.Close()
        tempStream.Seek(0, SeekOrigin.Begin)
        Dim form As New Aspose.Pdf.Kit.Form(tempStream, outStream)
        Dim fld As String
        For Each fld In form.FieldsNames
          If fld.GetTypeCode <> TypeCode.String Then
            MsgBox(fld.GetTypeCode())
          End If
          form.FillField(fld, fld)
        Next
        form.Save()
        outStream.Close()
        inStream.Close()
        Dim viewer As New Aspose.Pdf.Kit.PdfViewer
        viewer.OpenPdfFile(outputFile)
        Dim ps As New System.Drawing.Printing.PrinterSettings
        Dim page As New System.Drawing.Printing.PageSettings
        ps.PrinterName = "HP LaserJet 4300 PCL 6"
        viewer.PrintDocumentWithSettings(page, ps)
        viewer.ClosePdfFile()
        MsgBox("Done")


    Allen Wen
    Developer
    Aspose Changsha Team

    About Us
    Contact Us
     
View as RSS news feed in XML