@@ -44,38 +44,36 @@ PdfHtmlParams htmlParams // html conversion params
4444 stm . Destroy ( ) ;
4545 }
4646
47+ //htmlParams.type = PdfHtmlType.kPdfHtmlResponsive;
4748 htmlParams . flags |= PdfToHtml . kHtmlNoExternalCSS | PdfToHtml . kHtmlNoExternalJS |
4849 PdfToHtml . kHtmlNoExternalIMG | PdfToHtml . kHtmlNoExternalFONT ;
49- htmlParams . image_params . format = PdfImageFormat . kImageFormatJpg ;
50+ //htmlParams.image_params.format = PdfImageFormat.kImageFormatJpg;
51+ //htmlParams.image_params.quality = 80;
5052
5153 PdfHtmlDoc htmlDoc = pdfToHtml . OpenHtmlDoc ( doc ) ;
5254 if ( htmlDoc == null )
5355 throw new Exception ( pdfix . GetError ( ) ) ;
5456
55- // save common js and css for all pages
56- PsStream docCss = pdfix . CreateMemStream ( ) ;
57- if ( ! pdfToHtml . SaveCSS ( docCss ) )
58- throw new Exception ( pdfix . GetError ( ) ) ;
59- docCss . Destroy ( ) ;
60- 61- PsStream docJs = pdfix . CreateMemStream ( ) ;
62- if ( ! pdfToHtml . SaveJavaScript ( docJs ) )
63- throw new Exception ( pdfix . GetError ( ) ) ;
64- docJs . Destroy ( ) ;
65- 66- PsStream docStm = pdfix . CreateMemStream ( ) ;
67- if ( ! htmlDoc . SaveDocHtml ( docStm , htmlParams , null , IntPtr . Zero ) )
68- throw new Exception ( pdfix . GetError ( ) ) ;
69- docStm . Destroy ( ) ;
57+ var docStm = pdfix . CreateFileStream ( Utils . GetAbsolutePath ( "output" ) + "/pages.html" , PsFileMode . kPsTruncate ) ;
58+ 59+ // prepare head
60+ docStm . Write ( 0 , System . Text . Encoding . Default . GetBytes ( "<html>\n <head>\n <title>PDFix sample</title>\n </head>\n <body>\n " ) ) ;
61+ docStm . Write ( docStm . GetSize ( ) , System . Text . Encoding . Default . GetBytes ( "<script>\n " ) ) ;
62+ pdfToHtml . SaveJavaScript ( docStm ) ;
63+ docStm . Write ( docStm . GetSize ( ) , System . Text . Encoding . Default . GetBytes ( "\n </script>\n <style>\n " ) ) ;
64+ pdfToHtml . SaveCSS ( docStm ) ;
65+ docStm . Write ( docStm . GetSize ( ) , System . Text . Encoding . Default . GetBytes ( "\n </style>\n " ) ) ;
7066
67+ // convert pages
7168 for ( int i = 0 ; i < doc . GetNumPages ( ) ; i ++ )
7269 {
73- PsStream pageStm = pdfix . CreateMemStream ( ) ;
74- if ( ! htmlDoc . SavePageHtml ( pageStm , htmlParams , i , null , IntPtr . Zero ) )
70+ if ( ! htmlDoc . SavePageHtml ( docStm , htmlParams , i , null , IntPtr . Zero ) )
7571 throw new Exception ( pdfix . GetError ( ) ) ;
76- pageStm . Destroy ( ) ;
7772 }
7873
74+ docStm . Write ( docStm . GetSize ( ) , System . Text . Encoding . Default . GetBytes ( "</body>\n </html>" ) ) ;
75+ 76+ docStm . Destroy ( ) ;
7977 htmlDoc . Close ( ) ;
8078 doc . Close ( ) ;
8179 pdfToHtml . Destroy ( ) ;
0 commit comments