Zum Hauptinhalt springen
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
Windows Tipps & SecurityGrafikkarte vor Überhitzung schützen: So geht’s(25.09.2026 um 08:00 Uhr)
••••••••••
Windows Tipps & SecurityGrafikkarte vor Überhitzung schützen: So geht’s(25.09.2026 um 08:00 Uhr)
••••••••••
Intelligence View
⚡ tsecurity.de Intelligence

The PDF document preview capability of Web components

Previewing PDF Documents with Web Components in HarmonyOS Next Overview The Web component in HarmonyOS Next provides the capability to preview PDF documents within web pages. Applications can load PDF documents using the src…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!




Previewing PDF Documents with Web Components in HarmonyOS Next






Overview



The Web component in HarmonyOS Next provides the capability to preview PDF documents within web pages. Applications can load PDF documents using the src parameter or the loadUrl() interface of the Web component. Depending on the source of the PDF document, there are three common scenarios: loading PDF documents from the internet, loading local PDF documents, and loading PDF documents from application resources.






Prerequisites



If your PDF preview involves fetching documents from the internet, ensure that you have configured the necessary network access permissions in the module.json5 file:




"requestPermissions":[
{
"name" : "ohos.permission.INTERNET"
}
]






For more information on declaring permissions in the configuration file, refer to the official documentation.






Example: Loading PDF Documents



In the following example, the Web component is configured to load a PDF document from the internet by default. The URL https://www.example.com/test.pdf is used as an example and should be replaced with a real, accessible address.






Application-Side Code






// xxx.ets
import { webview } from '@kit.ArkWeb';

@Entry
@Component
struct WebComponent {
controller: webview.WebviewController = new webview.WebviewController();

build() {
Column() {
Web({
src: "https://www.example.com/test.pdf", // Method 1: Load PDF from the internet
// getContext(this).filesDir + "/test.pdf", // Method 2: Load local PDF from the application sandbox
// "resource://rawfile/test.pdf", // Method 3: Load PDF from application resources
// $rawfile('test.pdf'), // Method 4: Load PDF from application resources
controller: this.controller
})
.domStorageAccess(true)
}
}
}









Explanation





  • Method 1: Load a PDF document from the internet using a URL.


  • Method 2: Load a local PDF document from the application's sandbox directory. This requires the fileAccess permission.


  • Method 3: Load a PDF document from the application's resources using the resource://rawfile/ scheme.


  • Method 4: Load a PDF document from the application's resources using the $rawfile function.






Configuring PDF Preview Parameters



You can control the initial state of the PDF preview by configuring specific parameters in the URL. The supported parameters include:





  • nameddest=destination: Specifies a named destination within the PDF document.


  • page=pagenum: Specifies the page number in the document, with the first page being 1.


  • zoom=scale zoom=scale,left,top: Sets the zoom level and scroll position. For example, a zoom value of 100 represents 100% zoom. The scroll values are based on the coordinate system, with 0,0 being the top-left corner of the visible page, regardless of document rotation.


  • toolbar=1 | 0: Opens or closes the top toolbar.


  • navpanes=1 | 0: Opens or closes the side navigation pane.






URL Examples






https://example.com/test.pdf#Chapter6
https://example.com/test.pdf#page=3
https://example.com/test.pdf#zoom=50
https://example.com/test.pdf#page=3&zoom=200,250,100
https://example.com/test.pdf#toolbar=0
https://example.com/test.pdf#navpanes=0


Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten The PDF document preview capability of Web components

Thematisch verwandte Begriffe: document, preview, capability, components · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

💬 Kommentare werden geladen…
Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-100896 | A weakness has been identified in TOTOLINK N150RT 3.4.0-B20201030. The …
Advisory →
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag